<%@ page language="java" contentType="text/html; charset=utf-8"
	pageEncoding="utf-8"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>


<title>POS收单运营管理平台</title>

<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<link href="<s:url value="/css/common.less"/>" type="text/less"
	rel="stylesheet" />
	<link href="<s:url value="/css/common.css"/>" type="text/css"
	rel="stylesheet" />

<script type="text/javascript" src="<s:url value="/js/jquery-1.3.2.js" />"></script>
<script type="text/javascript" src="<s:url value="/js/jquery-1.9.1.js" />"></script>
<script type="text/javascript" 	src="<s:url value="/js/jquery.blockUI.js" />"></script>
<script type="text/javascript" src="<s:url value="/js/query_Address.js" />"></script>
<script type='text/javascript' src='<s:url value="/dwr/interface/AddressQuery.js"/>'></script>
<script type="text/javascript" src="<s:url value="/js/jquery.validate.min.js" />"></script>
<script type="text/javascript" src="<s:url value="/js/pwms.validate.js?v13" />"></script>
<script language="javascript" type="text/javascript" src="<s:url value="/js/My97DatePicker/WdatePicker.js"/>"></script>
<script type='text/javascript' src='<s:url value="/js/pageAjax.js"/>'></script>
<script type='text/javascript' src='<s:url value="/js/YLlightbox.js"/>'></script>
<script type='text/javascript' src='<s:url value="/dwr/interface/BankQuery.js"/>'></script>

<script type="text/javascript" src="<s:url value="/js/jquery-1.9.1.js" />"></script>
<script type="text/javascript" src="<s:url value="/js/query_Address.js" />"></script>
<script type="text/javascript" src="<s:url value="/js/jquery.validate.js" />"></script>
<script type="text/javascript" src="<s:url value="/js/pwms.validate.js" />"></script>
<script type="text/javascript" src="<s:url value="/js/My97DatePicker/WdatePicker.js"/>"></script>
<script type="text/javascript" src="<s:url value="/dwr/engine.js"/>"></script>
<script type='text/javascript' src='<s:url value="/dwr/interface/AddressQuery.js"/>'></script>
<script type='text/javascript' src='<s:url value="/dwr/interface/BankQuery.js"/>'></script>
<script type='text/javascript' src='<s:url value="/js/YLlightbox.js"/>'></script>
<script type='text/javascript' src='<s:url value="/js/ajaxfileupload.js"/>'></script>
<script type='text/javascript' src='<s:url value="/js/pageAjax.js"/>'></script>

<!-- jQuery UI 插件 -->
<link rel="stylesheet" href=<s:url value="/css/jquery.ui.all.css"/>>
<script src=<s:url value="/js/ui/jquery.ui.core.js"/>></script>
<script src=<s:url value="/js/ui/jquery.ui.widget.js"/>></script>
<script src=<s:url value="/js/ui/jquery.ui.position.js"/>></script>
<script src=<s:url value="/js/ui/jquery.ui.menu.js"/>></script>
<script src=<s:url value="/js/ui/jquery.ui.autocomplete.js"/>></script>
<link rel="stylesheet" href=<s:url value="/css/demos.css"/>>
<style>
		 .fieldError { color: red; text-align: left; }
		.error { float: none; color: red;  vertical-align: top;font-size: 11px;}
		.ui-autocomplete {
		max-height: 200px;
		overflow-y:auto;
		overflow-x: hidden;
	}
	/* IE 6 doesn't support max-height
	 * we use height instead, but this forces the menu to always be this tall
	 */
	* html .ui-autocomplete {
		height: 100px;
	}
	</style>
<style type="text/css">

.error {
	color: red;
}

</style>
<script type="text/javascript">

	$(document).ready(function() {
		//检查是什么状态，更新或新增
		var flag="${flag}";
		if(flag=="update"){
			$("#InsManageForm").attr("action","<%=basePath%>/org/updateOrg.ct");
		}else{
			$("#InsManageForm").attr("action","<%=basePath%>/org/addInsInfo.ct");
		}

		var bankMap = $("#bankListHidden").val();
    	var bankMapArray = bankMap.substring(1,bankMap.length-1).split(",");
  		$( "#tags" ).autocomplete({
  			source: bankMapArray  ,select:function(event,ui){
  				$("#aaa").val("");
  				$("#bbb").val("");
  				var optionValue = ui.item.value;
  				
  				if(optionValue){
  					obtainSomeBank(optionValue);
  				}
  			}  
  		});
  		var bankMap1 = $("#bankListHidden").val();
    	var bankMapArray1 = bankMap1.substring(1,bankMap1.length-1).split(",");
  		$( "#tags1" ).autocomplete({
  			source: bankMapArray1  ,select:function(event,ui){
  				$("#aaa1").val("");
  				$("#bbb1").val("");
  				var optionValue = ui.item.value;
  				
  				if(optionValue){
  					obtainSomeBank1(optionValue);
  				}
  			}  
  		});
		$("#InsManageForm").validate({
			debug : true,
			submitHandler : function(form) {
				$("#btnAdd").attr("disabled",true);
					form.submit();
			},
			rules : {
				"bean.InsName" : {required : true},		
				"bean.InsProvCd" : {required : true},
				"bean.InsCityCd" : {required : true}
			},
			messages : {
				"bean.InsName" : {required : "必填"},	
				"bean.InsProvCd" : {required :  "必选"},
				"bean.InsCityCd" : {required :  "必选"}
			},errorPlacement: function(error, element) { 
			    if ( element.is(":radio") ) 
			        error.appendTo ( element.parent() ); 
			    else if ( element.is(":checkbox") ) 
			        error.appendTo ( element.parent() ); 
			    else if ( element.is("input") ) {
			    	error.appendTo ( element.parent() ); 
			    }
			    else 
			        error.insertAfter(element); 
			} 

		});
		
	});
   function obtainSomeBank(mvalue) {
		
		var valArray = mvalue.split("_");
		BankQuery.loadBankInfo($.trim(valArray[0]), function(objs) {
			var someBankNameArray = [];
			
			for(var i=0;i<objs.length;i++){
				
				someBankNameArray.push(objs[i].name);
			}
			$("#aaa").autocomplete({
				source : someBankNameArray,select:function(event,ui){
					var zhBankName = ui.item.value;
					for(var i=0;i<objs.length;i++){
						if(zhBankName == objs[i].name){
							$("#bbb").val(objs[i].code);
							break;
						}
					}
				}
			});
		});
	}
   function obtainSomeBank1(mvalue) {
		
		var valArray = mvalue.split("_");
		BankQuery.loadBankInfo($.trim(valArray[0]), function(objs) {
			var someBankNameArray = [];
			
			for(var i=0;i<objs.length;i++){
				
				someBankNameArray.push(objs[i].name);
			}
			$("#aaa1").autocomplete({
				source : someBankNameArray,select:function(event,ui){
					var zhBankName = ui.item.value;
					for(var i=0;i<objs.length;i++){
						if(zhBankName == objs[i].name){
							$("#bbb1").val(objs[i].code);
							break;
						}
					}
				}
			});
		});
	}
</script>
</head>

<body>
<s:form id="InsManageForm"  method="post"  theme="simple"  >
<s:hidden id="areaCode"  value="%{#request.areaCode}"/>
	<table width="100%" class="tb" >
        <tr class="tb-line">
            <td class="tb-td" colspan="4">
	            <div class="tb-h2">POS收单运营管理平台</div>
		   	</td>
        </tr>
              <tr class="tb-line bg-gray">
            <td class="tb-td" colspan="4"><div class="tb-h3"><s:if test="#request.flag ==\"update\"">
                	修改收单机构
                	</s:if>
                	<s:else>
                	添加收单机构
                	</s:else></div></td>
        </tr>
		<tr class="tb-line">						
		    <td align="right" class="tb-td" style="width:150px;">
	        	<div class="tb-h4">机构名称：</div>
            </td>
            <td class="tb-td" >
	            <s:if test="#request.flag ==\"update\"">
	            <s:textfield maxLength="250" name="bean.InsName" style="width:250px;"
						cssClass="queryWidth" id="InsName" value="%{bean.InsName}"/>
				<s:hidden name="bean.InsIdCd"></s:hidden>
	           	</s:if>
	           	<s:else>
	            <s:textfield maxLength="250" name="bean.InsName" style="width:250px;"
						cssClass="queryWidth" id="InsName"/>
				</s:else>
				<font color="red">*</font>
			</td>
			<td align="right" class="tb-td" style="width:150px;">
	        	<div class="tb-h4">机构类型：</div>
            </td>
			<td class="tb-td" >   
				 <s:textfield maxLength="250" name="bean.InsType" 
						cssClass="queryWidth" id="InsType" value="收单机构" readonly="true"/>
			</td>
		</tr>
		<tr class="tb-line">
		    <td align="right" class="tb-td" style="width:150px;" >
	        	<div class="tb-h4">机构所在省市：</div>
            </td>
		    <td class="tb-td"  colspan="3">
		    <s:if test="#request.flag ==\"update\"">
			 <s:select id="chooseProvice" name="bean.InsProvCd" listKey="key" listValue="value"   list="#request.provinesMap" ></s:select>
            <font color="red">*</font>-<s:select id="chooseCity" list="#{'':'请选择' }"   name="bean.InsCityCd"/><font color="red">*</font>
            </s:if>
	        <s:else>
	        <s:select id="chooseProvice" name="bean.InsProvCd" listKey="key" listValue="value"   list="#request.provinesMap"  headerKey="" headerValue="---请选择---" ></s:select>
            <font color="red">*</font>-<s:select id="chooseCity" list="#{'':'请选择' }"   name="bean.InsCityCd"/><font color="red">*</font>
	        </s:else>
	        </td>
		</tr>	
		<tr class="tb-line">
			<td align="right" class="tb-td" style="width:150px;">
		        <div class="tb-h4">机构清算方式：</div>
	        </td>
			<td class="tb-td" >   
		 	<s:if test="#request.flag ==\"update\"">
	           	<s:select name="bean.InsStlmTp" list="#{'1':'非自主','0':'自主'}" cssClass="queryWidth" />
	        </s:if>
	        <s:else>
				<s:select name="bean.InsStlmTp" list="#{'1':'非自主','0':'自主'}" value="1"  cssClass="queryWidth" />
		    </s:else>
			</td>
			<td align="right" class="tb-td" style="width:150px;">
		        <div class="tb-h4">机构分润清算周期：</div>
	        </td> 
			<td class="tb-td">
		 	<s:if test="#request.flag ==\"update\"">
	           	<s:select name="bean.InsAloStlmCycle" list="#{'0':'日结','1':'周结','2':'月结','3':'季结','4':'半年结','5':'年结'}"   cssClass="queryWidth" />
	        </s:if>
	        <s:else>
				<s:select name="bean.InsAloStlmCycle" list="#{'0':'日结','1':'周结','2':'月结','3':'季结','4':'半年结','5':'年结'}" value="0"  cssClass="queryWidth" />
			</s:else>
			</td>
		</tr>
		<tr class="tb-line">
		    <td align="right" class="tb-td" style="width:150px;">
		        <div class="tb-h4">机构分润清算模式：</div>
	        </td>
			<td class="tb-td" >   
			<s:if test="#request.flag ==\"update\"">
	           	<s:select name="bean.InsAloStlmMd" list="#{'0':'T+0','1':'T+1'}"  cssClass="queryWidth" />
	        </s:if>
	        <s:else> 
				<s:select name="bean.InsAloStlmMd" list="#{'0':'T+0','1':'T+1'}" value="0"  cssClass="queryWidth" />
		    </s:else>
			</td>
			<td align="right" class="tb-td" style="width:150px;">
	        	<div class="tb-h4">机构状态</div>
            </td>
			<td class="tb-td" >   
			<s:if test="#request.flag ==\"update\"">
			<s:select name="bean.InsSta" list="#{'0':'注销','1':'正常'}" value="1"  cssClass="queryWidth"/>
			</s:if>
			<s:else>
			<s:select name="bean.InsSta" list="#{'1':'正常'}" value="1"  cssClass="queryWidth" />
			</s:else>
			</td>
		</tr>
		<tr class="tb-line">
		    <td align="right" class="tb-td" style="width:150px;">
		        <div class="tb-h4">收入账号：</div>
	        </td>
			<td class="tb-td">   
			<s:if test="#request.flag ==\"update\"">
			<s:textfield maxLength="250" name="bean.InsStlmCAcct" style="width:250px;"
						cssClass="queryWidth" id="InsStlmCAcct" value="%{bean.InsStlmCAcct}"/>
	        </s:if>
	        <s:else> 
				<s:textfield maxLength="250" name="bean.InsStlmCAcct" style="width:250px;"
						cssClass="queryWidth" id="InsStlmCAcct"/>
			</s:else>			
			</td>
			<td align="right" class="tb-td" style="width:150px;">
		        <div class="tb-h4">收入账户户名：</div>
	        </td>
			<td class="tb-td" >   
			<s:if test="#request.flag ==\"update\"">
				<s:textfield maxLength="250" name="bean.InsStlmCNm" style="width:250px;"
						cssClass="queryWidth" id="InsStlmCNm" value="%{bean.InsStlmCNm}"/>
	        </s:if>
	        <s:else> 
				<s:textfield maxLength="250" name="bean.InsStlmCNm" style="width:250px;"
						cssClass="queryWidth" id="InsStlmCNm"/>
			</s:else>
			</td>
		</tr>
		<tr class="tb-line" style="width:100%">
               <td width="7%" style="width:250px;" align="right" class="tb-td"  >
                    <div class="tb-h4">收入账户开户行行名：</div>
                </td>
                <td class="tb-td"   >
                <span><input type="hidden" value="<s:property value="#request.bMapToList"/>" id="bankListHidden">
		        <input id="tags" style="width:150px" placeholder="输入银行">-<input id="aaa" name="bean.InsStlmCBkNm"  placeholder="输入支行" style="width:250px"></span>
                </td>
                <td align="right" class="tb-td"  >
                    <div class="tb-h4">收入账户开户行行号：</div>
                </td>
                <td class="tb-td"   >
                <label class="tb-input-lengthen">
                    	<s:textfield id="bbb" name="bean.InsStlmCBkNo" maxLength="12" readonly="true" cssStyle="background-color:lightgray;"/>
                </label> 
                </td>
          </tr>	
		<tr class="tb-line">
		    <td align="right" class="tb-td" style="width:150px;">
		        <div class="tb-h4">支出账号：</div>
	        </td>
			<td class="tb-td"  > 
			<s:if test="#request.flag ==\"update\"">
			<s:textfield maxLength="250" name="bean.InsStlmDAcct" style="width:250px;"
						cssClass="queryWidth" id="InsStlmDAcct" value="%{bean.InsStlmDAcct}"/>
	         
	        </s:if>
	        <s:else>   
				<s:textfield maxLength="250" name="bean.InsStlmDAcct" style="width:250px;"
						cssClass="queryWidth" id="InsStlmDAcct"/>
			</s:else>
			</td>
			<td align="right" class="tb-td" style="width:150px;">
		        <div class="tb-h4">支出账户户名：</div>
	        </td>
			<td class="tb-td" >  
			<s:if test="#request.flag ==\"update\"">
			<s:textfield maxLength="250" name="bean.InsStlmDNm" style="width:250px;"
						cssClass="queryWidth" id="InsStlmDNm" value="%{bean.InsStlmDNm}"/>
	         
	        </s:if>
	        <s:else>  
				<s:textfield maxLength="250" name="bean.InsStlmDNm" style="width:250px;"
						cssClass="queryWidth" id="InsStlmDNm"/>
			</s:else>
			</td>
		</tr>
		<tr class="tb-line" style="width:100%">
               <td width="7%" style="width:250px;" align="right" class="tb-td"  >
                    <div class="tb-h4">支出账户开户行行名：</div>
                </td>
                <td class="tb-td"   >
                    <span><input type="hidden" value="<s:property value="#request.bMapToList"/>" id="bankListHidden1">
		        <input id="tags1" style="width:150px" placeholder="输入银行">-<input id="aaa1" name="bean.InsStlmDBkNm"  placeholder="输入支行" style="width:250px"></span> 
                </td>
                <td align="right" class="tb-td"  >
                    <div class="tb-h4">支出账户开户行行号：</div>
                </td>
                <td class="tb-td"   >
                  <label class="tb-input-lengthen">
                  	<s:textfield id="bbb1" name="bean.InsStlmDBkNo" maxLength="12" readonly="true" cssStyle="background-color:lightgray;"/>
                  </label>
                </td>
          </tr>
	</table>		
     <table width="100%" border="0" cellspacing="0" class="table">
          	<tr class="tb-line">
			<td colspan="4" align="center"><span style="color: red"><s:actionerror /></span>
				<span style="color: red;"><s:actionmessage /></span > <span style="color: red;"><s:fielderror
						cssClass="fieldError" /></span>
				<span id="otherError"></span>
			</td>
		</tr>
		<tr class="tb-line">
            <td class="tb-td line-submit" align="center" colspan="4">
                <label class="tb-input-submit">		                
                	<s:submit id="btnAdd" value="保  存" />								
				</label>
                <label class="tb-input-submit">
					<input type="reset" value="取  消"/>
				</label>
				<label class="tb-input-submit">
					<input type="button" value="返回" onclick="history.back()"/>
				</label>
			</td>
		</tr>
         </table>
</s:form>	
</body>
</html>
